﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CaseReivew.Model;
using CaseReview.Model;
using CaseReview.SQLServerDAL;
using Utility;

public partial class Reviewer_showDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack) {

            string id = Request.QueryString["id"];
            //ViewState["id"] = Request.Params[0];
            //string id = ViewState["id"].ToString();
            CaseInfo caseInfo = BusinessLogic.GetInstance().GetCaseInfoByCaseId(id);
          //  CaseInfo caseInfo = (CaseInfo) Session["CaseInfo"];
            Label66.Text = caseInfo.CaseId;
            Label67.Text = caseInfo.ReviewerName;
            Label68.Text = caseInfo.Title;
            Label69.Text = caseInfo.Age;
            Label72.Text = caseInfo.Labor;
            Label75.Text = caseInfo.Idle;
            Label70.Text = caseInfo.Owner;
            Label73.Text = caseInfo.Severity;
            Label76.Text = caseInfo.Phase;
            Label71.Text = caseInfo.ServicelLevel;
            Label74.Text = caseInfo.Type;
            Label77.Text = caseInfo.CountOfOwner;
        }
    }

    protected void btnSummit_Click(object sender, EventArgs e) {
        ReviewResultInfo result = new ReviewResultInfo();
        result.CaseId = Label66.Text;
        result.Reviewer = Label67.Text;
        result.Date = DateTime.Now;
        result.Owner = Label70.Text;
        result.Cac1 = DropDownList1.Text;
        result.Cac2 = DropDownList2.Text;
        result.Cac3 = DropDownList3.Text;
        result.Cac4 = DropDownList17.Text;
        result.Bac1 = DropDownList4.Text;
        result.Bac2 = DropDownList5.Text;
        result.Bac3 = DropDownList6.Text;
        result.Nce1 = DropDownList7.Text;
        result.Nce2 = DropDownList8.Text;
        result.Nce3 = DropDownList9.Text;
        result.Nce4 = DropDownList10.Text;
        result.Nce5 = DropDownList11.Text;
        result.Nce6 = DropDownList12.Text;
        result.Nce7 = DropDownList13.Text;
        result.Nce8 = DropDownList14.Text;
        result.Nce9 = DropDownList15.Text;
        result.Nce10 = DropDownList16.Text;
        result.Cac1C = TextBox1.Text;
        result.Cac2C = TextBox2.Text;
        result.Cac3C = TextBox3.Text;
        result.Cac4C = TextBox19.Text;
        result.Bac1C = TextBox4.Text;
        result.Bac2C = TextBox5.Text;
        result.Bac3C = TextBox6.Text;
        result.Nce1C = TextBox7.Text;
        result.Nce2C = TextBox8.Text;
        result.Nce3C = TextBox9.Text;
        result.Nce4C = TextBox10.Text;
        result.Nce5C = TextBox11.Text;
        result.Nce6C = TextBox12.Text;
        result.Nce7C = TextBox13.Text;
        result.Nce8C = TextBox14.Text;
        result.Nce9C = TextBox15.Text;
        result.Nce10C = TextBox16.Text;
        result.Osum = TextBox17.Text;
        result.Osug = TextBox18.Text;
        result.Status = 0;
        BusinessLogic.GetInstance().InsertReviewResults(result);
        CaseInfo caseInfo = BusinessLogic.GetInstance().GetCaseInfoByCaseId(result.CaseId);
        caseInfo.Status = 2;
        BusinessLogic.GetInstance().UpdateCase(caseInfo, result.CaseId);
        string ownerEmailAddress = caseInfo.Owner + "@microsoft.com";
        SendMail.SendToCaseOwnerResultMail(caseInfo, result, ownerEmailAddress);
        Response.Write("<script>window.opener.location.reload();</script>"); 
        Response.Write("<script>window.opener=null;window.open('','_self');window.close();</script>");
 
    }
    protected void btnReset_Click(object sender, EventArgs e) {

    }
}